<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Chat Room | Any-Chat</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

    <style>

    </style>
</head>
<!--<body style="background-color: #f1f1f1; padding-bottom: 0">-->
<body>

<!-- Start Content -->
<div class="row">
        <div class="panel panel-primary col-md-6">
            <div class="panel-heading">Panel heading without title</div>
            <div class="panel-body">
                <button type="button" id="start_analyse" class="btn btn-danger">开始分析</button>
            </div>
        </div>

        <div class="panel panel-info col-md-6">
            <div class="panel-heading">Panel heading without title</div>
            <div class="panel-body" id="show-grade">
                Panel content
            </div>
        </div>
</div>






<script>

    function showMessage(message) {
        $("#messageWindow").append("<div class='message-div row'>"+
            "<div style='display: inline-block; margin-right: 5px;' >"+
            "<img class='media-object f-image img-circle' style='position: absolute' src=" + message.avatar + ">"+
            "</div>"+
            " <div style='margin-left: 55px'>"+
            "<p class='user-nickname'>" + message.nickname + "</p> <p class='user-time'>"+message.sendTime+"</p><br>"+
            "<div class='message-box-left'>" + message.content + "</div></div></div><br>"
        );
    }

    $(function () {
                $("#start_analyse").click(function () {
                    ///start/analyse
                    $.get("analyse/show-grade").always(function(data) {
                        if(data.code == 200){
                            $("#show-grade").text(data.data)
                            // alert(data.data)

                        }else{
                            $("#response").text(JSON.stringify(data, null, 4));
                        }
                    });
                });

        /*$.get("analyse/show-grade").always(function(data) {
            if(data.code == 200){
                $("#show-grade").text(data.data)
                // alert(data.data)

            }else{
                $("#response").text(JSON.stringify(data, null, 4));
            }
        });*/



            /*$.ajax({
                url: '/login',
                method: 'POST',
                data:JSON.stringify(data)
            }).always(function(data, status, xhr) {
                if(status == "success"){
                    token = xhr.getResponseHeader("Authorization");
                    $("#login").hide();
                    $("#logout").show();
                    $("#notLoggedIn").hide();
                    $("#loggedIn").show();
                }else{
                    $("#response").text(JSON.stringify(data, null, 4));
                }
            });*/




            /*$.post("/api/common/add",
                {"friend" : friend},
                function(data){
                    if(data){
                        window.location.reload();
                    }else{
                        alert("用户不存在，添加失败！");
                    }
                }
            );*/


        $(".friend").click(function () {
            target = $(this).find("p.f-username").text();
            var nickname = $(this).find("h4.f-nickname").text();
            $("#target").text(nickname);
            $("#groupBtn").attr("class","btn btn-default");
        });

        $("#groupBtn").click(function(){
            $(this).attr("class","btn btn-default disabled");
            target = "TO_ALL";
            $("#target").text("所有人");
        });


        $("#addBtn").click(function(){
            var friend = $("#friendInput").val();
            if(friend.length == 0){
                return;
            }
            $.post("/api/common/add",
                {"friend" : friend},
                function(data){
                    if(data){
                        window.location.reload();
                    }else{
                        alert("用户不存在，添加失败！");
                    }
                }
            );
        });

    });

</script>
<!-- End Content -->
</body>
</html>